<?php
if($this_cata_info['cata_type'] == 0 || $this_cata_info['cata_type'] == 6 || $this_cata_info['cata_type'] == 11|| $this_cata_info['cata_type'] == 12) {
    // 分类文章
    $psize  = $this_list_psize;
    $page   = @(int)$_GET['page'];
    $key    = string_pre_process(trim(@$_REQUEST['key']));
    $cid    = @(int)$_GET['cid'];
    if($cid <= 0) {
        $cid = $this_cata_id;
    }
    $param  = array(
        'cid' => $this_cata_id,
        'title_length' => 40,
        );
    $side       = class_list($param, 1);
    $location   = location($cid);       // 当前位置：从当前文章的
	
    $thisclass  = & class_info($cid);
	$classname  = $thisclass['__text__'];
    listseo($thisclass);
    
    //  hr----

    // smarty变量
    $tpl->assign(array('psize'=>$psize,'page'=>$page,'classname'=>$classname));
    $tplfile    = $tpl_list;
} elseif($this_cata_info['cata_type'] == 1 || $this_cata_info['cata_type'] == 2) {
    // 多页文章
    $psize  = $this_list_psize;
    $page   = @(int)$_GET['page'];
    $cid        = $this_cata_id;
    // 多页文章得到当前文章
    $aid        = @(int)$_GET['aid'];
    // 得到文章列表和文章数据
    $side       = article_list(array(
                    'cid'=>$cid, 
                    'titlelen'=>40, 
                    'orderby0'=>'cata_order|ASC', 
                    'orderby1'=>'createtime|ASC'));
    $thisclass  = & $this_cata_info;    // 得到当前分类信息
    if(sizeof($side)>0 && $aid == 0) $aid = $side[$aid]['aid'];
    $acontent   = & article_content($aid);
    $location   = location($cid) ;//.'<font class="red fontB">'.$acontent['article_title'].'</font>';   // 得到当前路径
	$thisclass  = & class_info($cid);
    listseo($thisclass);
    //artseo($acontent, $thisclass); // 初始化页面seo数据

	$tpl->assign(array('page'=>$page,));
    // smarty变量
    $tpl->assign(array('acontent'=>$acontent));
    $tplfile    = $tpl_list;
} elseif($this_cata_info['cata_type'] == 3) {
    $cid        = $this_cata_id;        // 得到当前分类
    $location   = location($cid);       // 得到当前路径
    $thisclass  = & $this_cata_info;    // 得到当前分类信息
    $acontent   = & article_content($aid);
    artseo($acontent, $thisclass); // 初始化页面seo数据
    $side       = null;


    // smarty变量
    $tpl->assign(array('acontent'=>$acontent));
    $tplfile    = $tpl_list;
}
// 得到当前分类


//得到某类的子栏目
function getsub($cid)
{
	global $G_cfg;
	$newslist = array();
	if($cid=='35'||$cid=='36'||$cid=='37'||$cid=='38'||$cid=='39'||$cid=='58')
	    $sql = "SELECT cid,pid,cname FROM {$G_cfg['tblprefix']}article_class where pid=$cid order by cid";
	else
	    $sql = "SELECT cid,pid,cname FROM {$G_cfg['tblprefix']}article_class where pid in(select pid from {$G_cfg['tblprefix']}article_class where cid=$cid) order by cid";
    
	//echo $sql;
	//exit;
	$conn   = & get_db_conn();
	$rs = & $conn->Execute($sql);
    while (!$rs->EOF) 
	{
		$newslist[]    = array(
		    'cid' => $rs->fields['cid'],
		    'pid' => $rs->fields['pid'],
			'cname' => $rs->fields['cname'],
			);
		$rs->MoveNext();
	}
	return $newslist;
}

//得到左侧广告1
function getpagead1()
{
	global $G_cfg;
	$newslist = array();
	$sql = "select id,title,url,img from {$G_cfg['tblprefix']}ad where pagepos='inside' and pos='pos0' and display=1 order by id desc limit 0,1";
	$conn   = & get_db_conn();
	$rs = & $conn->Execute($sql);
    while (!$rs->EOF) 
	{
		$newslist[]    = array(
		    'id' => $rs->fields['id'],
		    'title' => $rs->fields['title'],
			'url' => $rs->fields['url'],
			'img' => $rs->fields['img'],
			);
		$rs->MoveNext();
	}
		return $newslist;
}

//得到左侧广告2
function getpagead2()
{
	global $G_cfg;
	$newslist = array();
	$sql = "select id,title,url,img from {$G_cfg['tblprefix']}ad where pagepos='inside' and pos='pos1' and display=1 order by id desc limit 0,1";
	$conn   = & get_db_conn();
	$rs = & $conn->Execute($sql);
    while (!$rs->EOF) 
	{
		$newslist[]    = array(
		    'id' => $rs->fields['id'],
		    'title' => $rs->fields['title'],
			'url' => $rs->fields['url'],
			'img' => $rs->fields['img'],
			);
		$rs->MoveNext();
	}
	return $newslist;
}


// 列表页分页信息
$tpl->assign(array(
    // 页面seo信息
    'page_title'    => $page_title,
    'seo_title'     => $seo_title,
    'seo_keywords'  => $seo_keywords,
    'seo_description' => $seo_description,

    'cid'   => $cid,
    'location'  => $location,
    'side'  => $side,
    'thisclass' => $thisclass,
	'getsub' => getsub($cid),
	'getpagead1' => getpagead1(),
	'getpagead2' => getpagead2(),
    ));



$tpl->display($tpl_sreach);
?>